import request from '@/utils/request'

export function getJobList() {
  return request({
    url: 'api/jobDef/getJobList?page=0&size=10&sort=sort%2Casc&sort=id%2Cdesc',
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'api/jobDef',
    method: 'post',
    data
  })
}

export function codeExit(data) {
  return request({
    url: 'api/jobDef/codeexit',
    method: 'post',
    data
  })
}

export function checkAppData(data) {
  return request({
    url: 'api/jobDef/checkAppData',
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: 'api/jobDef',
    method: 'put',
    data
  })
}

//
export function deleteTask(data) {
  return request({
    url: 'api/periodTaskDef/deleteTask',
    method: 'delete',
    data
  })
}

export function del(data) {
  return request({
    url: 'api/jobDef',
    method: 'delete',
    data
  })
}

export function selectCodes() {
  return request({
    url: 'api/agentDef/selectCodes',
    method: 'get'
  })
}

export function exportFile(data) {
  return request({
    url: 'api/jobDef/exportFile',
    method: 'post',
    responseType: 'blob',
    data
  })
}

export function batchUpdateStatus(data) {
  return request({
    url: 'api/jobDef/batchUpdateStatus',
    method: 'post',
    data
  })
}

export function batchUpdateJobPeriod(data) {
  return request({
    url: 'api/jobDef/batchUpdateJobPeriod',
    method: 'post',
    data
  })
}

export function batchUpdateOffsetHour(data) {
  return request({
    url: 'api/jobDef/batchUpdateOffsetHour',
    method: 'post',
    data
  })
}

export function batchUpdateSortNo(data) {
  return request({
    url: 'api/jobDef/batchUpdateSortNo',
    method: 'post',
    data
  })
}

export function batchUpdateDateRange(data) {
  return request({
    url: 'api/jobDef/batchUpdateDateRange',
    method: 'post',
    data
  })
}

export function initJobAndTaskInfo() {
  return request({
    url: 'api/jobDef/initJobAndTaskInfo',
    method: 'get'
  })
}

export function validateTaskCode(data) {
  return request({
    url: 'api/periodTaskDef/validateTaskCode',
    method: 'post',
    data
  })
}

export function toAddTask(data) {
  return request({
    url: 'api/periodTaskDef',
    method: 'post',
    data
  })
}

export function queryTaskList(jobCode) {
  return request({
    url: 'api/periodTaskDef/queryTaskList/' + jobCode,
    method: 'get'
  })
}

export function propToUpadate(data) {
  return request({
    url: 'api/periodTaskDef',
    method: 'put',
    data
  })
}

export function doDeleteByPkId(data) {
  return request({
    url: 'api/periodTaskDef/doDeleteByPkId',
    method: 'post',
    data
  })
}

export function getJobListByCurrentApp(data) {
  return request({
    url: 'api/jobDef/getJobListByCurrentApp',
    method: 'post',
    data
  })
}

export function qryJobDefByJobCode(jobCode) {
  return request({
    url: 'api/jobDef/qryJobDefByJobCode?jobCode=' + jobCode,
    method: 'get'
  })
}

export function qryTaskInfoByEchars(taskCode) {
  return request({
    url: 'api/periodTask/qryTaskInfoByEchars?taskCode=' + taskCode,
    method: 'get'
  })
}

export function qryTaskInfoByTables(data) {
  return request({
    url: 'api/periodTask/qryTaskInfoByTables',
    method: 'post',
    data
  })
}

export function queryTaskBytaskCode(data) {
  return request({
    url: 'api/periodTask/queryTaskBytaskCode',
    method: 'post',
    data
  })
}

export function generateTaskInstance(data) {
  return request({
    url: 'api/jobDef/generateTaskInstance',
    method: 'post',
    data
  })
}

export default {
  add,
  edit,
  del,
  codeExit,
  selectCodes,
  checkAppData,
  exportFile,
  batchUpdateStatus,
  batchUpdateOffsetHour,
  batchUpdateSortNo,
  initJobAndTaskInfo,
  validateTaskCode,
  toAddTask,
  queryTaskList,
  propToUpadate,
  doDeleteByPkId,
  getJobListByCurrentApp,
  qryJobDefByJobCode,
  batchUpdateDateRange,
  batchUpdateJobPeriod,
  qryTaskInfoByEchars,
  qryTaskInfoByTables,
  queryTaskBytaskCode,
  generateTaskInstance,
  getJobList
}
